package com.yeban.javase.day12.test.streamtest;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collector;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @Desc TODO
 * @Author yeban
 * @Date 2025/10/22
 */
public class StreamTest1 {

    public static void main(String[] args) {
        List<String> one = new ArrayList<>();
        one.add("迪丽热巴");
        one.add("宋远桥");
        one.add("苏星河");
        one.add("老子");
        one.add("庄子");
        one.add("孙子");
        one.add("洪七公");

        List<String> two = new ArrayList<>();
        two.add("古力娜扎");
        two.add("张无忌");
        two.add("张三丰");
        two.add("赵丽颖");
        two.add("张二狗");
        two.add("张天爱");
        two.add("张三");

        // 第一个队伍
        Stream<String> oneStream = one.stream().filter(p -> p.length() == 3).limit(3);
        // 第二个队伍
        Stream<String> twoStream = two.stream().filter(p -> p.startsWith("张")).skip(2);
        // 拼接
        Stream.concat(oneStream,twoStream).map(Person::new).forEach(System.out::println);

        // 一句话
        // Stream.concat(one.stream().filter(p -> p.length() == 3).limit(3),two.stream().filter(p -> p.startsWith("张")).skip(2)).map(Person::new).forEach(System.out::println);
    }
}

class Person {
    private String name;

    public Person() {
    }

    public Person(String name) {
        this.name = name;
    }

    /**
     * 获取
     * @return name
     */
    public String getName() {
        return name;
    }

    /**
     * 设置
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    public String toString() {
        return "Person{name = " + name + "}";
    }
}
